package com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.qingyiapp.R;
import com.example.qingyiapp.service.entify.FindChoicenessTwoBean;
import com.example.qingyiapp.service.entify.FindTJBean;

import java.util.ArrayList;

/**
 * Creadted by Met·Wang on 2019/9/18 14:36
 * Describe: NullPointerException Write
 */
public class FindChoicenessRecyclerAdapter extends RecyclerView.Adapter<FindChoicenessRecyclerAdapter.VHolder> {


    ArrayList<FindChoicenessTwoBean.DataBean> list;
    Context context;

    public FindChoicenessRecyclerAdapter(ArrayList<FindChoicenessTwoBean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }


    @NonNull
    @Override
    public VHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.fragment_find_recommend_item, null);

        return new VHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull VHolder vHolder, int i) {

            Glide.with(context).load(list.get(i).getPoststd()).into(vHolder.ig_image);
            Glide.with(context).load(list.get(i).getUsercover()).apply(RequestOptions.circleCropTransform()).into(vHolder.ig_icon);
            vHolder.tv_title.setText(list.get(i).getTitle()+"");
            vHolder.tv_userName.setText(list.get(i).getUser_name()+"");
            vHolder.tv_Content.setText(list.get(i).getSummary()+"");


    }



    @Override
    public int getItemCount() {
        return list.size();
    }

    class VHolder extends RecyclerView.ViewHolder{

        TextView tv_title;
        ImageView ig_image;
        ImageView ig_icon;
        TextView tv_userName;
        TextView tv_Content;



        public VHolder(@NonNull View itemView) {
            super(itemView);
            tv_title=itemView.findViewById(R.id.find_recommend_item_title);
            ig_image=itemView.findViewById(R.id.find_recommend_item_iamge);
            ig_icon=itemView.findViewById(R.id.find_recommend_item_icon);
            tv_userName=itemView.findViewById(R.id.find_recommend_item_userName);
            tv_Content=itemView.findViewById(R.id.find_recommend_item_content);



        }
    }

}
